package com.ymatou.operate.trading.api.testcase;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

import org.json.JSONArray;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.operate.trading.api.parameter.ChangeOrderDiscountBean;
import com.ymatou.operate.trading.api.parameter.PlaceOrderBean;
import com.ymatou.operate.trading.api.parameter.TradingCompletedNotifyRequestBean;
import com.ymatou.operate.trading.api.service.ChangeOrderDiscountCall;
import com.ymatou.operate.trading.api.service.PlaceOrderCall;
import com.ymatou.operate.trading.api.service.TradingCompletedNotifyRequestCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.CouponCallService;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.ProductCallService;
import com.ymttest.common.entitie.OrderInfo;
import com.ymttest.common.entitie.OrderProductInfo;
import com.ymttest.common.entitie.ProductActivityInfo;
import com.ymttest.common.enums.ActivityPromotionTypeEnum;
import com.ymttest.common.enums.AppTerminalSourceEnum;
import com.ymttest.common.enums.BondedAreaEnum;
import com.ymttest.common.enums.CancelOrderTypeEnum;
import com.ymttest.common.enums.LogisticsTypeEnum;
import com.ymttest.common.enums.OrderSourceEnum;
import com.ymttest.common.enums.OrderTypeEnum;
import com.ymttest.common.enums.PriceTypeEnum;
import com.ymttest.common.enums.ProductRefundChannelEnum;
import com.ymttest.common.enums.StockStatusEnum;
import com.ymttest.common.enums.TerminalSourceEnum;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

/**
 * 第三方支付和补款完回调通知接口 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_TradingCompletedNotifyRequest {
    private static TradingCompletedNotifyRequestBean tradingcompletenotifyrequestbean;

    private static TradingCompletedNotifyRequestCall tradingcompletenotifyrequestcall;

    @BeforeClass
    public static void setUp() {
        Logger.createResultFile("第三方支付和补款完回调通知接口");
    }

    @Before
    public void caseUp() {

        tradingcompletenotifyrequestbean = new TradingCompletedNotifyRequestBean();
        tradingcompletenotifyrequestcall = new TradingCompletedNotifyRequestCall();
    }

    @AfterClass
    public static void tearDown() {
        Logger.generateResult(tradingcompletenotifyrequestcall.getOpurl());
    }

    @After
    public void caseDown() {
        Logger.end();
    }

    @Test
    @Category(P1.class)
    @TestCase
    @Ignore
    public void Tc_TradingCompletedNotifyRequest_001() {
        Logger.start(true, "第三方补款，成功");
        try {
            // 创建订单
            Logger.comment("前置数据准备");
            Map map = new OrderCallService().appSaveOrder();
            int orderId = (Integer) map.get("orderId");
            int sellerId = (Integer) map.get("sellerId");
            int userId = (Integer) map.get("userId");
            int tradingId = (Integer) map.get("tradingId");
            DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
            BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
            // 支付前账户金额
            HashMap<String, Integer> m1 = new HashMap<String, Integer>();
            m1.put("UserId", userId);
            BigDecimal price1 = (BigDecimal) new DefaultWapper().selectAccountInfo(m1).get(0).get("fAvailAmount");
            // 支付
            new OrderCallService().orderPayRequest(userId, totalPrice, tradingId);
            // 接单
            new OrderCallService().acceptOrder(orderId, sellerId);
            // 卖家发起补款
            int price = 1 + new Random().nextInt(50);
            BigDecimal payAmount = new BigDecimal(df.format(price));
            String postPayId = new OrderCallService().applyForPostPay(orderId, sellerId, new BigDecimal(1));

            new OrderCallService().orderPostPayRequest(userId, payAmount, orderId);
            Logger.comment("前置数据准备结束");
            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice("price");
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-10 22:53:22");
            // 获取补款号
            String sid = new DefaultWapper().getPostPayTradingId(orderId);
            tradingcompletenotifyrequestbean.setTradingId(sid);
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setBizCode(1);
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            Logger.verifyEquals(ECode.SUCCESS, tradingcompletenotifyrequestcall.getCode(), "验证Code");
            // 数据库验证
            // 支付后金额
            Thread.sleep(3000);
            BigDecimal price2 = (BigDecimal) new DefaultWapper().selectAccountInfo(m1).get(0).get("fAvailAmount");
            HashMap<String, Integer> m = new HashMap<String, Integer>();
            m.put("OrderId", orderId);
            m.put("TradingStatus", 17);
            m.put("TraddingId", orderId);
            m.put("PaidInFull", 1);
            m.put("UserId", userId);
            Logger.verifyEquals(1, new DefaultWapper().selectOrder(m).size(), "验证订单表记录");
            Logger.verifyEquals(2, new DefaultWapper().selectTradingStatus(m).size(), "验证交易表记录");
            Logger.verifyEquals(totalPrice.add(new BigDecimal(price)), price1.subtract(price2), "验证账户金额");
            Logger.verifyEquals(1, new DefaultWapper().selectOrderPostPayByOrderId(orderId).get(0).get("iAction"),
                    "验证补款Action状态");
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_TradingCompletedNotifyRequest_002() {
        Logger.start(true, "第三方支付，成功");
        try {
            // 创建订单
            Logger.comment("前置数据准备");
            PlaceOrderResp placeOrderResp=new OrderCallService().createM2cOrder();

            int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
            int sellerId =placeOrderResp.getOrderList().get(0).getSellerId();
            int userId =placeOrderResp.getUserId();         
            int tradingId = placeOrderResp.getTradingId();

            BigDecimal totalPrice =  placeOrderResp.getPayAmount();// 支付金额
            // 获取支付前账户金额
            DefaultWapper database = new DefaultWapper();
            HashMap<String, Integer> m1 = new HashMap<String, Integer>();
            m1.put("UserId", userId);
            // 获取买家账户余额
            BigDecimal price1 = (BigDecimal) database.selectAccountInfo(m1).get(0).get("fAvailAmount");
            // 获取购买商品的金额
            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice("price");
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-09 22:53:22");
            tradingcompletenotifyrequestbean.setTradingId(String.valueOf(tradingId));
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setBizCode(3);
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            Logger.comment("tradingcompletenotifyrequestcall send:"
                    + tradingcompletenotifyrequestcall.getEntityString());
            Logger.comment("tradingcompletenotifyrequestcall response:"
                    + tradingcompletenotifyrequestcall.getReturnData());
            Logger.verifyEquals(ECode.SUCCESS, tradingcompletenotifyrequestcall.getCode(), "验证Code");
            // Logger.verifyEquals(ErrorCode.SUCCESSMSG,
            // apporderpaycall.getMsg(), "验证Msg");
            // 支付后金额
            BigDecimal price2 = (BigDecimal) database.selectAccountInfo(m1).get(0).get("fAvailAmount");
            HashMap<String, Integer> m = new HashMap<String, Integer>();
            m.put("OrderId", orderId);
            m.put("TradingStatus", 2);
            m.put("TraddingId", orderId);
            m.put("ReceiveUserId", sellerId);
            Logger.verifyEquals(1, database.selectOrder(m).size(), "验证订单表记录");
            Logger.verifyEquals(1, database.selectTradingStatus(m).size(), "验证交易状态表");
            Logger.verifyEquals(totalPrice, price1.subtract(price2), "验证账户金额");
            // Thread.sleep(3000);
            // Logger.verifyEquals(1, database.selectTradingNotifaction(m).size(), "验证交易通知表");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P3.class)
    @TestCase
    public void Tc_TradingCompletedNotifyRequest_003() {
        Logger.start(false, "交易号为空，失败");
        try {
            // 创建订单
            Logger.comment("前置数据准备");
            Map map = new OrderCallService().appSaveOrder();
            int orderId = (Integer) map.get("orderId");
            int sellerId = (Integer) map.get("sellerId");
            int userId = (Integer) map.get("userId");
            int tradingId = (Integer) map.get("tradingId");
            DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
            BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
            // 买家付款
            new OrderCallService().orderPayRequest(userId, totalPrice, tradingId);
            // 接单
            new OrderCallService().acceptOrder(orderId, sellerId);
            // 卖家发起补款
            int price = 1 + new Random().nextInt(50);
            BigDecimal payAmount = new BigDecimal(df.format(price));
            String postPayId = new OrderCallService().applyForPostPay(orderId, sellerId, payAmount);
            Logger.comment("前置数据准备结束");
            // 参数
            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice("price");
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-10 22:53:22");
            // 获取补款号
            tradingcompletenotifyrequestbean.setTradingId("");
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setBizCode(1);
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            Logger.verifyEquals(ECode.FAILED400, tradingcompletenotifyrequestcall.getCode(), "验证Code");
            Logger.verifyEquals(true, tradingcompletenotifyrequestcall.getMsg().contains(ECode.ERROR400_MSG_10),
                    "验证Msg" + tradingcompletenotifyrequestcall.getMsg());
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P3.class)
    @TestCase
    public void Tc_TradingCompletedNotifyRequest_004() {
        Logger.start(true, "交易号不存在，失败");
        try {
            // 创建订单
            Logger.comment("前置数据准备");
            Map map = new OrderCallService().appSaveOrder();
            int orderId = (Integer) map.get("orderId");
            int sellerId = (Integer) map.get("sellerId");
            int userId = (Integer) map.get("userId");
            int tradingId = (Integer) map.get("tradingId");
            DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
            BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
            // 买家付款
            new OrderCallService().orderPayRequest(userId, totalPrice, tradingId);
            // 接单
            new OrderCallService().acceptOrder(orderId, sellerId);
            // 卖家发起补款
            int price = 1 + new Random().nextInt(50);
            BigDecimal payAmount = new BigDecimal(df.format(price));
            String postPayId = new OrderCallService().applyForPostPay(orderId, sellerId, payAmount);
            Logger.comment("前置数据准备结束");
            // 参数
            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice("price");
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-10 22:53:22");
            // 获取补款号

            tradingcompletenotifyrequestbean.setTradingId("tradingiderror");
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setBizCode(1);
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            Logger.comment("tradingcompletenotifyrequestcall send:"
                    + tradingcompletenotifyrequestcall.getEntityString());
            Logger.comment("tradingcompletenotifyrequestcall response:"
                    + tradingcompletenotifyrequestcall.getReturnData());
            Logger.verifyEquals(ECode.FAILED201, tradingcompletenotifyrequestcall.getCode(), "验证Code");
            Logger.verifyEquals(true, tradingcompletenotifyrequestcall.getMsg().contains(ECode.FAILED201_MSG_19),
                    "验证Msg" + tradingcompletenotifyrequestcall.getMsg());
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P3.class)
    @TestCase
    public void Tc_TradingCompletedNotifyRequest_005() {
        Logger.start(true, "BizCode为空，失败");
        try {
            // 创建订单
            Logger.comment("前置数据准备");
            Map map = new OrderCallService().appSaveOrder();
            int orderId = (Integer) map.get("orderId");
            int sellerId = (Integer) map.get("sellerId");
            int userId = (Integer) map.get("userId");
            int tradingId = (Integer) map.get("tradingId");
            DecimalFormat df = new DecimalFormat("0.00");// 保留两位小数
            BigDecimal totalPrice = (BigDecimal) map.get("totalPrice");// 支付金额
            // 买家付款
            new OrderCallService().orderPayRequest(userId, totalPrice, tradingId);
            // 接单
            new OrderCallService().acceptOrder(orderId, sellerId);
            // 卖家发起补款
            int price = 1 + new Random().nextInt(50);
            BigDecimal payAmount = new BigDecimal(df.format(price));
            String postPayId = new OrderCallService().applyForPostPay(orderId, sellerId, payAmount);
            Logger.comment("前置数据准备结束");
            // 参数
            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice("price");
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-10 22:53:22");

            tradingcompletenotifyrequestbean.setTradingId(String.valueOf(tradingId));
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            Logger.comment("tradingcompletenotifyrequestcall send:"
                    + tradingcompletenotifyrequestcall.getEntityString());
            Logger.comment("tradingcompletenotifyrequestcall response:"
                    + tradingcompletenotifyrequestcall.getReturnData());
            Logger.verifyEquals(ECode.ERROR400, tradingcompletenotifyrequestcall.getCode(), "验证Code");
            Logger.verifyEquals(true, tradingcompletenotifyrequestcall.getMsg().contains(ECode.ERROR400_MSG_11),
                    "验证Msg");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P3.class)
    @TestCase
    // 第三方支付完成 回调交易，如果订单为取消状态走快速退款流程
    // 测试环境 快速退款失败
    public void Tc_TradingCompletedNotifyRequest_006() {
        Logger.start(true, "订单已取消");
        try {
        	PlaceOrderResp placeOrderResp=new OrderCallService().createM2cOrder();

        	int orderId = placeOrderResp.getOrderList().get(0).getOrderId();
        	int sellerId =placeOrderResp.getOrderList().get(0).getSellerId();
        	int userId =placeOrderResp.getUserId();         
        	int tradingId = placeOrderResp.getTradingId();

        	BigDecimal totalPrice =  placeOrderResp.getPayAmount();// 支付金额
            // 系统取消订单
            new OrderCallService().cancelOrder(orderId, userId, CancelOrderTypeEnum.SystemCancelOrder);

            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice("price");
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-10 22:53:22");
            tradingcompletenotifyrequestbean.setTradingId(String.valueOf(tradingId));
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setBizCode(3);
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            Logger.comment("tradingcompletenotifyrequestcall send:"
                    + tradingcompletenotifyrequestcall.getEntityString());
            Logger.comment("tradingcompletenotifyrequestcall response:"
                    + tradingcompletenotifyrequestcall.getReturnData());
            Logger.verifyEquals(ECode.FAILED201, tradingcompletenotifyrequestcall.getCode(), "验证Code");
            Logger.verifyEquals(ECode.FAILED201_MSG_68, tradingcompletenotifyrequestcall.getMsg(), "验证Msg");

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_TradingCompletedNotifyRequest_007() {
        Logger.start(true, "一个订单多个商品,第三方支付成功通知");
        try {
            DefaultWapper database = new DefaultWapper();
            OrderCallService orderService = new OrderCallService();
            // 创建订单
            Logger.comment("前置数据准备");
            Map map = placeOrder();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            JSONArray orders = (JSONArray) map.get("orders");
            int tradingId = (Integer) map.get("tradingId");

            List<Integer> orderList = new ArrayList<Integer>();
            int orderId1 = orders.getInt(0);
            int orderId2 = orders.getInt(1);
            orderList.add(orderId1);
            orderList.add(orderId2);

            // 获取用户需要支付的金额
            // 需要支付的定金
            BigDecimal needPayAmount1 = orderService.getNeedPrePayAmountOfCash(orderId1);
            BigDecimal needPayAmount2 = orderService.getNeedPrePayAmountOfCash(orderId2);
            // 2单总需要支付的定金
            BigDecimal needPayAmount = needPayAmount1.add(needPayAmount2);

            // 第三方支付的钱
            BigDecimal thirdPayAmount = new BigDecimal(32);
            // 通过余额支付的钱;
            BigDecimal payAmount = needPayAmount.subtract(thirdPayAmount);

            // 买家付款
            int newTradingId = orderService.orderPayRequest(userId, payAmount, tradingId);

            // 支付前账户金额
            HashMap<String, Integer> m1 = new HashMap<String, Integer>();
            m1.put("UserId", userId);
            BigDecimal price1 = (BigDecimal) database.selectAccountInfo(m1).get(0).get("fAvailAmount");

            Logger.comment("前置数据准备结束");
            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice("price");
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-10 22:53:22");
            tradingcompletenotifyrequestbean.setTradingId(String.valueOf(newTradingId));
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setBizCode(3);
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            Logger.verifyEquals(ECode.SUCCESS, tradingcompletenotifyrequestcall.getCode(), "验证Code");
            // 数据库验证
            // 支付后金额
            Thread.sleep(3000);
            BigDecimal price2 = (BigDecimal) new DefaultWapper().selectAccountInfo(m1).get(0).get("fAvailAmount");
            HashMap<String, Integer> m = new HashMap<String, Integer>();
            m.put("OrderId", orderId1);
            m.put("TradingStatus", 2);
            m.put("TraddingId", orderId1);
            m.put("UserId", userId);
            Logger.verifyEquals(1, new DefaultWapper().selectOrder(m).size(), "验证订单表记录");

            verifyDb(newTradingId, orderList, needPayAmount, thirdPayAmount);
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_TradingCompletedNotifyRequest_008() {
        Logger.start(true, "一个订单多个商品,混合支付第三方补款成功通知");
        try {
            DefaultWapper database = new DefaultWapper();
            OrderCallService orderService = new OrderCallService();
            // 创建订单
            Logger.comment("前置数据准备");
            Map map = placeOrder();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            JSONArray orders = (JSONArray) map.get("orders");
            int tradingId = (Integer) map.get("tradingId");
            int orderId1 = orders.getInt(0);
            int orderId2 = orders.getInt(1);

            // 获取用户需要支付的金额
            // 需要支付的定金
            BigDecimal needPayAmount1 = orderService.getNeedPrePayAmountOfCash(orderId1);
            BigDecimal needPayAmount2 = orderService.getNeedPrePayAmountOfCash(orderId2);
            // 2单总需要支付的定金
            BigDecimal needPayAmount = needPayAmount1.add(needPayAmount2);
            // 买家付款 全部余额支付
            int newTradingId = orderService.orderPayRequest(userId, needPayAmount, tradingId);
            // 接单
            orderService.acceptOrder(orderId1, sellerId);
            orderService.acceptOrder(orderId2, sellerId);

            // 定金+补款
            BigDecimal payableAmount1 = orderService.getPayableAmount(orderId1);
            BigDecimal payableAmount2 = orderService.getPayableAmount(orderId1);
            BigDecimal payableAmount = payableAmount1.add(payableAmount2);
            // 需要补款的金额
            BigDecimal payAmount1 = payableAmount1.subtract(needPayAmount1);
            BigDecimal payAmount2 = payableAmount2.subtract(needPayAmount2);
            // 申请补款
            orderService.applyForPostPay(orderId1, sellerId, payAmount1);
            // 申请补款
            orderService.applyForPostPay(orderId2, sellerId, payAmount2);
            // 第三方支付的钱
            BigDecimal thirdPayAmount1 = new BigDecimal(32);
            BigDecimal thirdPayAmount2 = new BigDecimal(23);
            // 通过余额支付的钱;
            BigDecimal payYmtAmount1 = payAmount1.subtract(thirdPayAmount1);
            BigDecimal payYmtAmount2 = payAmount2.subtract(thirdPayAmount2);
            // 补款1
            orderService.orderPostPayRequest(userId, payYmtAmount1, orderId1);
            // 补款2
            orderService.orderPostPayRequest(userId, payYmtAmount2, orderId2);

            // 支付前账户金额
            HashMap<String, Integer> m1 = new HashMap<String, Integer>();
            m1.put("UserId", userId);
            BigDecimal price1 = (BigDecimal) database.selectAccountInfo(m1).get(0).get("fAvailAmount");

            Logger.comment("前置数据准备结束");
            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice(thirdPayAmount1.toString());
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-10 22:53:22");
            // 获取补款号
            String sid = new DefaultWapper().getPostPayTradingId(orderId1);
            tradingcompletenotifyrequestbean.setTradingId(sid);
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setBizCode(1);
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            Logger.verifyEquals(ECode.SUCCESS, tradingcompletenotifyrequestcall.getCode(), "验证Code");
            // 数据库验证
            // 新交易号，订单号，补款的余额，补款第三方
            verifyDb2(newTradingId, orderId1, payYmtAmount1, thirdPayAmount1);
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_TradingCompletedNotifyRequest_009() {
        Logger.start(true, "一个订单多个商品,混合支付第三方补款成功通知");
        try {
            DefaultWapper database = new DefaultWapper();
            OrderCallService orderService = new OrderCallService();
            // 创建订单
            Logger.comment("前置数据准备");
            Map map = placeOrder();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            JSONArray orders = (JSONArray) map.get("orders");
            int tradingId = (Integer) map.get("tradingId");
            int orderId1 = orders.getInt(0);
            int orderId2 = orders.getInt(1);

            // 获取用户需要支付的金额
            // 需要支付的定金
            BigDecimal needPayAmount1 = orderService.getNeedPrePayAmountOfCash(orderId1);
            BigDecimal needPayAmount2 = orderService.getNeedPrePayAmountOfCash(orderId2);
            // 2单总需要支付的定金
            BigDecimal needPayAmount = needPayAmount1.add(needPayAmount2);
            // 买家付款 全部余额支付
            int newTradingId = orderService.orderPayRequest(userId, needPayAmount, tradingId);
            // 接单
            orderService.acceptOrder(orderId1, sellerId);
            orderService.acceptOrder(orderId2, sellerId);

            // 定金+补款
            BigDecimal payableAmount1 = orderService.getPayableAmount(orderId1);
            BigDecimal payableAmount2 = orderService.getPayableAmount(orderId2);
            BigDecimal payableAmount = payableAmount1.add(payableAmount2);
            // 需要补款的金额
            BigDecimal payAmount1 = payableAmount1.subtract(needPayAmount1);
            BigDecimal payAmount2 = payableAmount2.subtract(needPayAmount2);
            // 申请补款
            orderService.applyForPostPay(orderId1, sellerId, payAmount1);
            // 申请补款
            orderService.applyForPostPay(orderId2, sellerId, payAmount2);
            // 第三方支付的钱
            BigDecimal thirdPayAmount1 = new BigDecimal(32);
            BigDecimal thirdPayAmount2 = new BigDecimal(23);
            // 通过余额支付的钱;
            BigDecimal payYmtAmount1 = payAmount1.subtract(thirdPayAmount1);
            BigDecimal payYmtAmount2 = payAmount2.subtract(thirdPayAmount2);
            // 补款1
            orderService.orderPostPayRequest(userId, payYmtAmount1, orderId1);
            // 补款2
            orderService.orderPostPayRequest(userId, payYmtAmount2, orderId2);

            // 支付前账户金额
            HashMap<String, Integer> m1 = new HashMap<String, Integer>();
            m1.put("UserId", userId);

            BigDecimal price1 = (BigDecimal) database.selectAccountInfo(m1).get(0).get("fAvailAmount");

            Logger.comment("前置数据准备结束");
            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice(thirdPayAmount2.toString());
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-10 22:53:22");
            // 获取补款号
            String sid = new DefaultWapper().getPostPayTradingId(orderId2);
            tradingcompletenotifyrequestbean.setTradingId(sid);
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setBizCode(1);
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            BigDecimal price2 = (BigDecimal) database.selectAccountInfo(m1).get(0).get("fAvailAmount");
            Logger.verifyEquals(ECode.SUCCESS, tradingcompletenotifyrequestcall.getCode(), "验证Code");
            Logger.verifyEquals(price1.subtract(price2), payAmount2, "验证用户的可用余额扣减为用户补款ymt余额的金额");
            // 数据库验证
            verifyDb2(newTradingId, orderId2, payYmtAmount2, thirdPayAmount2);
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category(P1.class)
    @TestCase
    public void Tc_TradingCompletedNotifyRequest_010() {
        Logger.start(true, "一个订单多个商品,全部第三方支付");
        try {
            DefaultWapper database = new DefaultWapper();
            // 创建订单
            Logger.comment("前置数据准备");
            ChangeOrderDiscountBean changeorderdiscountbean = new ChangeOrderDiscountBean();
            ChangeOrderDiscountCall changeorderdiscountcall = new ChangeOrderDiscountCall();

            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            Map map = placeOrder2();
            int orderId = (Integer) map.get("orderId");
            int tradingId = (Integer) map.get("tradingId");
            Logger.comment("前置数据准备结束");
            // 参数
            BigDecimal discount = new BigDecimal(17);
            changeorderdiscountbean.setDiscount(discount);
            String discountTime = YMTDateUtil.getSysTime();
            changeorderdiscountbean.setDiscountTime(discountTime);
            BigDecimal freight = new BigDecimal(38);
            changeorderdiscountbean.setFreight(freight);
            changeorderdiscountbean.setOrderId(orderId);
            changeorderdiscountbean.setSellerId(sellerId);
            // 发送请求
            changeorderdiscountcall.setData(changeorderdiscountbean);
            changeorderdiscountcall.callService();
            OrderCallService orderCallService = new OrderCallService();
            // 定金金额
            BigDecimal earnestAmount = orderCallService.getNeedPrePayAmountOfCash(orderId);
            // 全款金额
            BigDecimal totalAmount = orderCallService.getPayableAmount(orderId);
            // 付款
            orderCallService.orderPayRequest(userId, earnestAmount, tradingId);
            // 接单
            orderCallService.acceptOrder(orderId, sellerId);
            // 申请补款
            orderCallService.applyForPostPay(orderId, sellerId,
                    totalAmount.subtract(earnestAmount).add(new BigDecimal(-20)));
            // 全部第三方补款
            orderCallService.orderPostPayRequest(userId, new BigDecimal(0), orderId);

            Logger.comment("前置数据准备结束");
            tradingcompletenotifyrequestbean.setAppId(1);
            tradingcompletenotifyrequestbean.setVersion(1);
            // 此接口的价格不用传，因为接口不会按照这个参数进行支付。
            tradingcompletenotifyrequestbean.setPayPrice("100");
            tradingcompletenotifyrequestbean.setCurrency("CNY");
            tradingcompletenotifyrequestbean.setTraceId("123456");
            tradingcompletenotifyrequestbean.setPayTime("2015-09-10 22:53:22");
            // 获取补款号
            String sid = new DefaultWapper().getPostPayTradingId(orderId);
            tradingcompletenotifyrequestbean.setTradingId(sid);
            tradingcompletenotifyrequestbean.setPaymentId("radamnumber");
            tradingcompletenotifyrequestbean.setExternalUserId("radamuserId");
            tradingcompletenotifyrequestbean.setInstPaymentId("radamInstPaymentId");
            tradingcompletenotifyrequestbean.setBizCode(1);
            tradingcompletenotifyrequestbean.setParamExt("");
            tradingcompletenotifyrequestbean.setSignMethod("");
            tradingcompletenotifyrequestbean.setSign("");
            // 发送请求
            tradingcompletenotifyrequestcall.setData(tradingcompletenotifyrequestbean);
            tradingcompletenotifyrequestcall.callService();
            /*
             * BigDecimal price2 = (BigDecimal)
             * database.selectAccountInfo(m1).get(0).get("fAvailAmount");
             * Logger.verifyEquals(ECode.SUCCESS, tradingcompletenotifyrequestcall.getCode(),
             * "验证Code"); Logger.verifyEquals(price1.subtract(price2), payAmount2,
             * "验证用户的可用余额扣减为用户补款ymt余额的金额"); // 数据库验证 verifyDb2(newTradingId, orderId2,
             * payYmtAmount2, thirdPayAmount2);
             */
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    // 校验第三方支付通知
    private void verifyDb(int tradingId, List<Integer> orderIds, BigDecimal needPayAmount, BigDecimal thirdPayAmount) {
        DefaultWapper database = new DefaultWapper();
        for (int i = 0; i < orderIds.size(); i++) {
            int orderId = orderIds.get(i);
            // 订单主表
            List<Map> ymtOrders = database.selectOrderByOderId(orderId);
            // 订单商品明细
            List<Map> ymtOrdersInfoList = database.selectOrderInfoByOderId(orderId);
            // ymtOrderState 表
            List<Map> ymtOrderState = database.selectOrderStateByOderId(orderId);
            // ymt_orderpay 表
            List<Map> ymtOrderPay = database.selectOrderPay(orderId);
            // Ymt_OrderPostPay 表
            List<Map> ymtOrderPostPay = database.selectOrderPostPayByOrderId(orderId);
            // 优惠券金额
            BigDecimal couponValue = (BigDecimal) ymtOrders.get(0).get("CouponValue");
            // 商家用户优惠券金额
            BigDecimal sellerCouponValue = (BigDecimal) ymtOrders.get(0).get("fSellerCouponAmount");
            // 平台用户优惠券金额
            BigDecimal ymtCouponValue = (BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount");
            // 查询当前订单需要支付的定金
            BigDecimal orderNeedPayAmount = new OrderCallService().getNeedPrePayAmountOfCash(orderId);

            BigDecimal dtemp = new BigDecimal(0);
            BigDecimal orderThirdParty = new BigDecimal(0);
            BigDecimal rate = orderNeedPayAmount.divide(needPayAmount, 5, BigDecimal.ROUND_HALF_DOWN);
            Logger.debug("rate:" + rate);

            if (i == orderIds.size()) {
                orderThirdParty = thirdPayAmount.subtract(dtemp);
            }
            else {
                orderThirdParty = rate.multiply(thirdPayAmount).divide(new BigDecimal(1), 2, BigDecimal.ROUND_HALF_UP);
            }

            Logger.comment("验证订单号:" + orderId);
            Logger.comment("验证ymt_order表");
            Logger.verifyEquals(
                    2,
                    (Integer) ymtOrders.get(0).get("iTradingStatus"), "验证iTradingStatus");
            Logger.comment("验证ymt_orderState表");
            Logger.verifyEquals(1, ymtOrderState.size(), "验证ymt_orderState表");
            Logger.verifyEquals(
                    couponValue,
                    (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfCoupon"), "验证fPaidAmountOfCoupon");
            // 余额+第三方支付
            Logger.verifyEquals(
                    orderNeedPayAmount,
                    (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfCash"), "验证fPaidAmountOfCash");
            Logger.verifyEquals(
                    sellerCouponValue,
                    (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfSellerCoupon"), "验证fPaidAmountOfSellerCoupon");
            Logger.verifyEquals(
                    ymtCouponValue,
                    (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfYmtCoupon"), "验证fPaidAmountOfYmtCoupon");

            Logger.verifyEquals(
                    orderNeedPayAmount.subtract(orderThirdParty),
                    (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfYmtAccount"), "验证fPaidAmountOfYmtAccount");
            Logger.verifyEquals(
                    orderThirdParty,
                    (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfThirdParty"), "验证fPaidAmountOfThirdParty");

            Logger.comment("验证ymt_orderpay表");
            Logger.verifyEquals(
                    tradingId,
                    (Integer) ymtOrderPay.get(0).get("iTradingId"), "验证iTradingId");
            Logger.verifyEquals(
                    2,
                    (Integer) ymtOrderPay.get(0).get("iPayType"), "验证iPayType");
            Logger.verifyEquals(
                    orderNeedPayAmount,
                    (BigDecimal) ymtOrderPay.get(0).get("fAmount"), "验证fAmount");
            Logger.verifyEquals(
                    0,
                    (Integer) ymtOrderPay.get(0).get("iStatus"), "验证iStatus");
            Logger.verifyEquals(
                    "支付网关回调处理成功",
                    (String) ymtOrderPay.get(0).get("sMemo"), "验证sMemo");
            Logger.verifyEquals(
                    1,
                    (Integer) ymtOrderPay.get(0).get("iAccountingNum"), "验证iAccountingNum");
            Logger.verifyEquals(
                    "操作成功！",
                    (String) ymtOrderPay.get(0).get("sAccountingMessage"), "验证sAccountingMessage");
            dtemp = dtemp.add(orderThirdParty);

        }

        // ymt_tradinginfo 表
        List<Map> ymtTradinginfo = database.selectTradinginfoByTradingId(tradingId);
        Logger.comment("验证ymt_tradinginfo表");
        Logger.verifyEquals(
                thirdPayAmount.setScale(2),
                (BigDecimal) ymtTradinginfo.get(0).get("fAmount"), "验证fAmount");
        Logger.verifyEquals(
                2,
                (Integer) ymtTradinginfo.get(0).get("iTradingStatus"), "验证iTradingStatus");
        Logger.verifyEquals(
                needPayAmount,
                (BigDecimal) ymtTradinginfo.get(0).get("fPayableAmount"), "验证fPayableAmount");
    }

    // 校验第三方补款通知
    private void verifyDb2(int tradingId, int orderId, BigDecimal payAmount, BigDecimal thirdPayAmount) {
        // 用户支付的余额
        DefaultWapper database = new DefaultWapper();
        // 订单主表
        List<Map> ymtOrders = database.selectOrderByOderId(orderId);
        // 订单商品明细
        List<Map> ymtOrdersInfoList = database.selectOrderInfoByOderId(orderId);
        // ymt_tradinginfo 表
        List<Map> ymtTradinginfo = database.selectTradinginfoByTradingId(tradingId);
        // ymtOrderState 表
        List<Map> ymtOrderState = database.selectOrderStateByOderId(orderId);
        // Ymt_OrderPostPay 表
        List<Map> ymtOrderPostPay = database.selectOrderPostPayByOrderId(orderId);
        // 需要支付的定金
        BigDecimal needPayAmount1 = new OrderCallService().getNeedPrePayAmountOfCash(orderId);
        // 优惠券金额
        BigDecimal couponValue = (BigDecimal) ymtOrders.get(0).get("CouponValue");
        // 商家用户优惠券金额
        BigDecimal sellerCouponValue = (BigDecimal) ymtOrders.get(0).get("fSellerCouponAmount");
        // 平台用户优惠券金额
        BigDecimal ymtCouponValue = (BigDecimal) ymtOrders.get(0).get("fYmtCouponAmount");

        Logger.comment("验证订单号:" + orderId);
        Logger.comment("验证ymt_order表");
        Logger.verifyEquals(
                17,
                (Integer) ymtOrders.get(0).get("iTradingStatus"), "验证iTradingStatus");

        Logger.comment("验证ymt_orderState表");
        Logger.verifyEquals(1, ymtOrderState.size(), "验证ymt_orderState表");
        Logger.verifyEquals(
                couponValue,
                (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfCoupon"), "验证fPaidAmountOfCoupon");
        // 补款支付总额
        Logger.verifyEquals(
                payAmount.add(thirdPayAmount),
                (BigDecimal) ymtOrderState.get(0).get("fPostPaidAmountOfCash"), "验证fPostPaidAmountOfCash");
        Logger.verifyEquals(
                sellerCouponValue,
                (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfSellerCoupon"), "验证fPaidAmountOfSellerCoupon");
        Logger.verifyEquals(
                ymtCouponValue,
                (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfYmtCoupon"), "验证fPaidAmountOfYmtCoupon");
        // 定金付款ymt余额
        Logger.verifyEquals(
                needPayAmount1,
                (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfYmtAccount"), "验证fPaidAmountOfYmtAccount");
        // 定金付款第三方金额
        Logger.verifyEquals(
                BigDecimal.ZERO.setScale(2),
                (BigDecimal) ymtOrderState.get(0).get("fPaidAmountOfThirdParty"), "验证fPaidAmountOfThirdParty");
        // 补款付款ymt余额
        Logger.verifyEquals(
                payAmount,
                (BigDecimal) ymtOrderState.get(0).get("fPostPaidAmountOfYmtAccount"), "验证fPostPaidAmountOfYmtAccount");
        // 补款付款第三方金额
        Logger.verifyEquals(
                thirdPayAmount.setScale(2),
                (BigDecimal) ymtOrderState.get(0).get("fPostPaidAmountOfThirdParty"), "验证fPostPaidAmountOfThirdParty");

    }


    // 一次下单生成2个订单号,分别使用平台,商家优惠券,每个订单下面3个商品
    private Map placeOrder() {
        Map map = new HashMap();
        try {
            PlaceOrderBean placeorderBean = new PlaceOrderBean();
            PlaceOrderCall placeorderCall = new PlaceOrderCall();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            // 创建产品
            Logger.comment("前置数据准备");
            HashMap<String, Object> productInfo = ProductCallService.createProduct(sellerId, 3);
            Logger.comment("前置数据准备结束");
            String productId = (String) productInfo.get("productId");
            Logger.debug("productId:" + productId);
            String productName = (String) productInfo.get("productName");
            String pic = (String) productInfo.get("pic");
            BigDecimal price = (BigDecimal) (productInfo.get("price"));
            // String catalogId = (String) productInfo.get("catalogId");
            // 买家用户等级
            int userLevel = 3;
            // 订单来源
            int orderSource = OrderSourceEnum.APP.getValue();
            placeorderBean.setOrderSource(orderSource);
            // 终端来源
            int terminalSource = TerminalSourceEnum.IOS.getValue();
            placeorderBean.setTerminalSource(terminalSource);
            // 应用终端来源
            int appTerminalSource = AppTerminalSourceEnum.Phone.getValue();
            placeorderBean.setAppTerminalSource(appTerminalSource);
            // SourceIp
            String sourceIp = "127.0.0.1";
            placeorderBean.setSourceIp(sourceIp);
            // 用户设备号
            String deviceId = "";
            placeorderBean.setDeviceId(deviceId);
            // 订单信息List
            List<OrderInfo> orderInfoList = new ArrayList<OrderInfo>();
            OrderInfo order = new OrderInfo();
            // 订单类型
            int orderType = OrderTypeEnum.Shangou.getValue();
            order.setOrderType(orderType);
            // 卖家
            order.setSellerId(sellerId);
            String leaveWord = "autotest";
            order.setLeaveWord(leaveWord);
            // 运费
            BigDecimal freight = new BigDecimal(23);
            order.setFreight(freight);
            // 优惠券
            // 领用优惠券
            BigDecimal couponValue = new BigDecimal(10);
            // 领用商家优惠券
            String couponCode = new CouponCallService().receiveCouponInfo(sellerId, userId, couponValue);
            order.setCouponCode(couponCode);
            // 优惠券类型
            int couponType = 1;
            order.setCouponUseType(couponType);
            // 优惠券渠道
            int couponChannel = 2;
            order.setCouponChannel(couponChannel);
            // 优惠券金额
            order.setCouponValue(couponValue);
            // 是否全额付款
            boolean isPaidFull = false;
            order.setIsPaidFull(isPaidFull);
            // 收货地址
            String address = "上海市闸北区灵石路636号";
            order.setAddress(address);
            // 邮编
            String postCode = "200001";
            order.setPostCode(postCode);
            // 收件人姓名
            String receieveName = "李四";
            order.setReceieveName(receieveName);
            // 收货人手机号
            String phone = "13100000001";
            order.setPhone(phone);
            // 收货人电话
            String telephone = "021-51002100";
            order.setTelephone(telephone);
            // 自动取消小时数
            BigDecimal autoCancelOrderHours = new BigDecimal(10);
            order.setAutoCancelOrderHours(autoCancelOrderHours);
            // 订单商品信息
            List<OrderProductInfo> orderProductInfoList = new ArrayList<OrderProductInfo>();
            OrderProductInfo productinfo = new OrderProductInfo();
            OrderProductInfo productinfo2 = new OrderProductInfo();
            OrderProductInfo productinfo3 = new OrderProductInfo();
            // 商品id
            productinfo.setProductId(productId);
            // 商品名称
            productinfo.setProductName(productName);
            // 商品规格id
            String catalogId = TestDataManager.getRandomUUID().toString();
            productinfo.setCatalogId(catalogId);
            // 备货状态(1-现货 2-代购 3-FBX)
            int catalogType = StockStatusEnum.Spot.getValue();
            productinfo.setStockStatusEnum(catalogType);
            // 商品数量
            int productNum = 1 + new Random().nextInt(5);
            productinfo.setProductNum(productNum);
            // 商品一级目录id
            int firstCategoryId = 1;
            productinfo.setFirstCategoryId(firstCategoryId);
            // 商品一级目录id
            int secondCategoryId = 2;
            productinfo.setSecondCategoryId(secondCategoryId);
            // 商品一级目录id
            int thirdCategoryId = 3;
            productinfo.setThirdCategoryId(thirdCategoryId);
            // 商品品牌id
            int brandId = 5;
            productinfo.setBrandId(brandId);
            // 商品url
            productinfo.setPictureUrl(pic);
            // 商品属性信息(按JSON格式存储，如--颜色:黑色,尺寸:XXS)
            String propetyInfo = "";
            productinfo.setPropetyInfo(propetyInfo);
            // 商品价格
            BigDecimal productPrice = price;
            productinfo.setProductPrice(productPrice);
            // 商品预付定金价格
            BigDecimal earnestPrice = price.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP); // 小数点后保留2位并四舍五入
            productinfo.setEarnestPrice(earnestPrice);
            // 价格类型
            int priceType = PriceTypeEnum.Unkown.getValue();
            productinfo.setPriceType(priceType);
            // 买家或卖家承担关税(0-卖家承担 1-买家承担)
            int tariffType = 0;
            productinfo.setTariffType(tariffType);
            // 物流类型
            int logisticsType = LogisticsTypeEnum.SailProtect.getValue();
            productinfo.setLogisticsType(logisticsType);
            // 保税区
            int bondedArea = BondedAreaEnum.NingBo.getValue();
            productinfo.setBondedArea(bondedArea);
            // 商品备案号
            String productRecordNo = "123456";
            productinfo.setProductRecordNo(productRecordNo);
            // SKU
            String sku = "1234567";
            productinfo.setSKU(sku);
            // 套餐编号
            String packageNo = "11111111";
            productinfo.setPackageNo(packageNo);
            // 商品退货渠道
            int productRefundChannel = ProductRefundChannelEnum.Official.getValue();
            productinfo.setProductRefundChannel(productRefundChannel);
            // 商品信息(存储格式为：Json格式)
            String productDetailInfo =
                    "e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男";
            productinfo.setProductDetailInfo(productDetailInfo);
            // 活动商品信息
            ProductActivityInfo activityInfo = new ProductActivityInfo();
            // 商品活动号
            int activityId = 46870;
            activityInfo.setActivityId(activityId);
            // 额外费用
            BigDecimal premium = new BigDecimal(10);
            activityInfo.setPremium(premium);
            // 是否算入成本价
            boolean isCost = false;
            activityInfo.setIsCost(isCost);
            // 是否使用优惠券
            boolean isUseCoupon = false;
            activityInfo.setIsUseCoupon(isUseCoupon);
            // 是否免佣金
            boolean isFeeFree = false;
            activityInfo.setIsFeeFree(isFeeFree);
            // 活动开始时间
            String beginDate = YMTDateUtil.getBeforeOrNextDay(-100);
            activityInfo.setActivityBeginDate(beginDate);
            // 活动结束时间
            String endDate = YMTDateUtil.getBeforeOrNextDay(10);
            activityInfo.setActivityEndDate(endDate);
            // 商品活动模板号
            int activityTemplateId = 987654;
            activityInfo.setActivityTemplateId(activityTemplateId);
            // 商品活动促销类型
            int promotionType = ActivityPromotionTypeEnum.DiscountPrice.getValue();
            activityInfo.setPromotionType(promotionType);
            // 促销价格
            BigDecimal promotionPrice = new BigDecimal(1);
            activityInfo.setPromotionPrice(promotionPrice);
            // 促销价格
            BigDecimal commissionRate = new BigDecimal(0);
            activityInfo.setCommissionRate(commissionRate);
            productinfo.setActivityInfo(activityInfo);
            // 第二件商品
            // 商品id
            productinfo2.setProductId(productId);
            // 商品名称
            productinfo2.setProductName(productName);
            // 商品规格id
            String catalogId2 = TestDataManager.getRandomUUID().toString();
            productinfo2.setCatalogId(catalogId2);
            // 备货状态(1-现货 2-代购 3-FBX)
            int catalogType2 = StockStatusEnum.Spot.getValue();
            productinfo2.setStockStatusEnum(catalogType2);
            // 商品数量
            int productNum2 = 1 + new Random().nextInt(5);
            productinfo2.setProductNum(productNum2);
            // 商品一级目录id
            int firstCategoryId2 = 1;
            productinfo2.setFirstCategoryId(firstCategoryId2);
            // 商品一级目录id
            int secondCategoryId2 = 2;
            productinfo2.setSecondCategoryId(secondCategoryId2);
            // 商品一级目录id
            int thirdCategoryId2 = 3;
            productinfo2.setThirdCategoryId(thirdCategoryId2);
            // 商品品牌id
            int brandId2 = 3;
            productinfo2.setBrandId(brandId2);
            // 商品url
            productinfo2.setPictureUrl(pic);
            // 商品属性信息(按JSON格式存储，如--颜色:黑色,尺寸:XXS)
            String propetyInfo2 = "";
            productinfo2.setPropetyInfo(propetyInfo2);
            // 商品价格
            BigDecimal productPrice2 = price;
            productinfo2.setProductPrice(productPrice2);
            // 商品预付定金价格
            BigDecimal earnestPrice2 = price.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP); // 小数点后保留2位并四舍五入
            productinfo2.setEarnestPrice(earnestPrice2);
            // 价格类型
            int priceType2 = PriceTypeEnum.NewPersonPrice.getValue();
            productinfo2.setPriceType(priceType2);
            // 买家或卖家承担关税(0-卖家承担 1-买家承担)
            int tariffType2 = 0;
            productinfo2.setTariffType(tariffType2);
            // 物流类型
            int logisticsType2 = LogisticsTypeEnum.XloboBondedDelivery.getValue();
            productinfo2.setLogisticsType(logisticsType2);
            // 保税区
            int bondedArea2 = BondedAreaEnum.NingBo.getValue();
            productinfo2.setBondedArea(bondedArea2);
            // 商品备案号
            String productRecordNo2 = "123456";
            productinfo2.setProductRecordNo(productRecordNo2);
            // SKU
            String sku2 = "1234567";
            productinfo2.setSKU(sku2);
            // 套餐编号
            String packageNo2 = "11111111";
            productinfo2.setPackageNo(packageNo2);
            // 商品退货渠道
            int productRefundChannel2 = ProductRefundChannelEnum.Official.getValue();
            productinfo2.setProductRefundChannel(productRefundChannel2);
            // 商品信息(存储格式为：Json格式)
            String productDetailInfo2 =
                    "e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男";
            productinfo2.setProductDetailInfo(productDetailInfo2);
            productinfo2.setActivityInfo(activityInfo);
            // 第三件商品
            // 商品id
            productinfo3.setProductId(productId);
            // 商品名称
            productinfo3.setProductName(productName);
            // 商品规格id
            String catalogId3 = TestDataManager.getRandomUUID().toString();
            productinfo3.setCatalogId(catalogId3);
            // 备货状态(1-现货 2-代购 3-FBX)
            productinfo3.setStockStatusEnum(catalogType);
            // 商品数量
            int productNum3 = 1 + new Random().nextInt(5);
            productinfo3.setProductNum(productNum3);
            // 商品一级目录id
            productinfo3.setFirstCategoryId(firstCategoryId);
            // 商品一级目录id
            productinfo3.setSecondCategoryId(secondCategoryId);
            // 商品一级目录id
            productinfo3.setThirdCategoryId(thirdCategoryId);
            // 商品品牌id
            int brandId3 = 3;
            productinfo3.setBrandId(brandId3);
            // 商品url
            productinfo3.setPictureUrl(pic);
            // 商品属性信息(按JSON格式存储，如--颜色:黑色,尺寸:XXS)
            String propetyInfo3 = "";
            productinfo3.setPropetyInfo(propetyInfo3);
            // 商品价格
            BigDecimal productPrice3 = price;
            productinfo3.setProductPrice(productPrice3);
            // 商品预付定金价格
            BigDecimal earnestPrice3 = price.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP); // 小数点后保留2位并四舍五入
            productinfo3.setEarnestPrice(earnestPrice3);
            // 价格类型
            int priceType3 = PriceTypeEnum.NewPersonPrice.getValue();
            productinfo3.setPriceType(priceType3);
            // 买家或卖家承担关税(0-卖家承担 1-买家承担)
            int tariffType3 = 0;
            productinfo3.setTariffType(tariffType3);
            // 物流类型
            int logisticsType3 = LogisticsTypeEnum.XloboBondedDelivery.getValue();
            productinfo3.setLogisticsType(logisticsType3);
            // 保税区
            int bondedArea3 = BondedAreaEnum.NingBo.getValue();
            productinfo3.setBondedArea(bondedArea3);
            // 商品备案号
            productinfo3.setProductRecordNo(productRecordNo);
            // SKU
            productinfo3.setSKU(sku);
            // 套餐编号
            productinfo3.setPackageNo(packageNo);
            // 商品退货渠道
            productinfo3.setProductRefundChannel(productRefundChannel);
            // 商品信息(存储格式为：Json格式)
            productinfo3.setProductDetailInfo(productDetailInfo);
            // 活动商品信息
            productinfo3.setActivityInfo(activityInfo);

            orderProductInfoList.add(productinfo);
            orderProductInfoList.add(productinfo2);
            orderProductInfoList.add(productinfo3);
            // 订单商品信息
            order.setOrderProductInfoList(orderProductInfoList);
            // 第二个订单
            OrderInfo order2 = new OrderInfo();
            // 订单类型
            int orderType2 = OrderTypeEnum.Shangou.getValue();
            order2.setOrderType(orderType2);
            // 卖家
            order2.setSellerId(sellerId);
            String leaveWord2 = "autotest";
            order2.setLeaveWord(leaveWord2);
            // 运费
            BigDecimal freight2 = new BigDecimal(20);
            order2.setFreight(freight2);
            // 优惠券
            BigDecimal couponValue2 = new BigDecimal(11);
            // ymt 平台优惠券
            String couponCode2 = new OrderCallService().receivePlatformCoupon(userId, couponValue);
            order2.setCouponCode(couponCode2);
            // 优惠券类型
            int couponType2 = 1;
            order2.setCouponUseType(couponType2);
            // 优惠券渠道 1 ymt平台，2 商家
            int couponChannel2 = 1;
            order2.setCouponChannel(couponChannel2);
            // 优惠券金额
            order2.setCouponValue(couponValue2);
            // 是否全额付款
            boolean isPaidFull2 = false;
            order2.setIsPaidFull(isPaidFull2);
            // 收货地址
            String address2 = "上海市闸北区灵石路636号";
            order2.setAddress(address2);
            // 邮编
            String postCode2 = "200001";
            order2.setPostCode(postCode2);
            // 收件人姓名
            String receieveName2 = "李四";
            order2.setReceieveName(receieveName2);
            // 收货人手机号
            String phone2 = "13100000002";
            order2.setPhone(phone2);
            // 收货人电话
            String telephone2 = "021-51002111";
            order2.setTelephone(telephone2);
            // 自动取消小时数
            BigDecimal autoCancelOrderHours2 = new BigDecimal(2);
            order2.setAutoCancelOrderHours(autoCancelOrderHours2);
            // 订单商品信息 拷贝第一单3个商品
            order2.setOrderProductInfoList(orderProductInfoList);
            // 订单信息
            orderInfoList.add(order);
            // 订单信息
            orderInfoList.add(order2);
            placeorderBean.setUserId(userId);
            placeorderBean.setOrderInfoList(orderInfoList);
            placeorderCall.setData(placeorderBean);
            placeorderCall.callService();
            JSONArray orders = placeorderCall.getOrderIds();
            int tradingId = placeorderCall.getTradingId();
            map.put("orders", orders);
            map.put("tradingId", tradingId);
        } catch (Exception e) {
            Logger.fail(e);
        }
        return map;
    }

    // 一次下单生成1个M订单，下面有3个商品
    private Map placeOrder2() {
        Map map = new HashMap();
        try {
            PlaceOrderBean placeorderBean = new PlaceOrderBean();
            PlaceOrderCall placeorderCall = new PlaceOrderCall();
            int userId = Integer.valueOf(EnvSetup.getData("BuyUserId"));
            int sellerId = Integer.valueOf(EnvSetup.getData("SellerId"));
            // 创建产品
            Logger.comment("前置数据准备");
            HashMap<String, Object> productInfo = ProductCallService.createProduct(sellerId, 3);
            Logger.comment("前置数据准备结束");
            String productId = (String) productInfo.get("productId");
            Logger.debug("productId:" + productId);
            String productName = (String) productInfo.get("productName");
            String pic = (String) productInfo.get("pic");
            BigDecimal price = (BigDecimal) (productInfo.get("price"));
            // String catalogId = (String) productInfo.get("catalogId");
            // 买家用户等级
            int userLevel = 3;
            // 订单来源
            int orderSource = OrderSourceEnum.APP.getValue();
            placeorderBean.setOrderSource(orderSource);
            // 终端来源
            int terminalSource = TerminalSourceEnum.IOS.getValue();
            placeorderBean.setTerminalSource(terminalSource);
            // 应用终端来源
            int appTerminalSource = AppTerminalSourceEnum.Phone.getValue();
            placeorderBean.setAppTerminalSource(appTerminalSource);
            // SourceIp
            String sourceIp = "127.0.0.1";
            placeorderBean.setSourceIp(sourceIp);
            // 用户设备号
            String deviceId = "";
            placeorderBean.setDeviceId(deviceId);
            // 订单信息List
            List<OrderInfo> orderInfoList = new ArrayList<OrderInfo>();
            OrderInfo order = new OrderInfo();
            // 订单类型
            int orderType = OrderTypeEnum.Shangou.getValue();
            order.setOrderType(orderType);
            // 卖家
            order.setSellerId(sellerId);
            String leaveWord = "autotest";
            order.setLeaveWord(leaveWord);
            // 运费
            BigDecimal freight = new BigDecimal(23);
            order.setFreight(freight);
            // 领用商家优惠券


            // 是否全额付款
            boolean isPaidFull = false;
            order.setIsPaidFull(isPaidFull);
            // 收货地址
            String address = "上海市闸北区灵石路636号";
            order.setAddress(address);
            // 邮编
            String postCode = "200001";
            order.setPostCode(postCode);
            // 收件人姓名
            String receieveName = "李四";
            order.setReceieveName(receieveName);
            // 收货人手机号
            String phone = "13100000001";
            order.setPhone(phone);
            // 收货人电话
            String telephone = "021-51002100";
            order.setTelephone(telephone);
            // 自动取消小时数
            BigDecimal autoCancelOrderHours = new BigDecimal(10);
            order.setAutoCancelOrderHours(autoCancelOrderHours);
            // 订单商品信息
            List<OrderProductInfo> orderProductInfoList = new ArrayList<OrderProductInfo>();
            OrderProductInfo productinfo = new OrderProductInfo();
            OrderProductInfo productinfo2 = new OrderProductInfo();
            OrderProductInfo productinfo3 = new OrderProductInfo();
            // 商品id
            productinfo.setProductId(productId);
            // 商品名称
            productinfo.setProductName(productName);
            // 商品规格id
            String catalogId = TestDataManager.getRandomUUID().toString();
            productinfo.setCatalogId(catalogId);
            // 备货状态(1-现货 2-代购 3-FBX)
            int catalogType = StockStatusEnum.Spot.getValue();
            productinfo.setStockStatusEnum(catalogType);
            // 商品数量
            int productNum = 1 + new Random().nextInt(5);
            productinfo.setProductNum(productNum);
            // 商品一级目录id
            int firstCategoryId = 1;
            productinfo.setFirstCategoryId(firstCategoryId);
            // 商品一级目录id
            int secondCategoryId = 2;
            productinfo.setSecondCategoryId(secondCategoryId);
            // 商品一级目录id
            int thirdCategoryId = 3;
            productinfo.setThirdCategoryId(thirdCategoryId);
            // 商品品牌id
            int brandId = 5;
            productinfo.setBrandId(brandId);
            // 商品url
            productinfo.setPictureUrl(pic);
            // 商品属性信息(按JSON格式存储，如--颜色:黑色,尺寸:XXS)
            String propetyInfo = "";
            productinfo.setPropetyInfo(propetyInfo);
            // 商品价格
            BigDecimal productPrice = new BigDecimal(110);
            productinfo.setProductPrice(productPrice);
            // 商品预付定金价格
            BigDecimal earnestPrice = new BigDecimal(26); // 小数点后保留2位并四舍五入
            productinfo.setEarnestPrice(earnestPrice);
            // 价格类型
            int priceType = PriceTypeEnum.Unkown.getValue();
            productinfo.setPriceType(priceType);
            // 买家或卖家承担关税(0-卖家承担 1-买家承担)
            int tariffType = 0;
            productinfo.setTariffType(tariffType);
            // 物流类型
            int logisticsType = LogisticsTypeEnum.SailProtect.getValue();
            productinfo.setLogisticsType(logisticsType);
            // 保税区
            int bondedArea = BondedAreaEnum.NingBo.getValue();
            productinfo.setBondedArea(bondedArea);
            // 商品备案号
            String productRecordNo = "123456";
            productinfo.setProductRecordNo(productRecordNo);
            // SKU
            String sku = "1234567";
            productinfo.setSKU(sku);
            // 套餐编号
            String packageNo = "11111111";
            productinfo.setPackageNo(packageNo);
            // 商品退货渠道
            int productRefundChannel = ProductRefundChannelEnum.Official.getValue();
            productinfo.setProductRefundChannel(productRefundChannel);
            // 商品信息(存储格式为：Json格式)
            String productDetailInfo =
                    "e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男";
            productinfo.setProductDetailInfo(productDetailInfo);
            // 活动商品信息
            ProductActivityInfo activityInfo = new ProductActivityInfo();
            // 商品活动号
            int activityId = 46870;
            activityInfo.setActivityId(activityId);
            // 额外费用
            BigDecimal premium = new BigDecimal(10);
            activityInfo.setPremium(premium);
            // 是否算入成本价
            boolean isCost = false;
            activityInfo.setIsCost(isCost);
            // 是否使用优惠券
            boolean isUseCoupon = false;
            activityInfo.setIsUseCoupon(isUseCoupon);
            // 是否免佣金
            boolean isFeeFree = false;
            activityInfo.setIsFeeFree(isFeeFree);
            // 活动开始时间
            String beginDate = YMTDateUtil.getBeforeOrNextDay(-100);
            activityInfo.setActivityBeginDate(beginDate);
            // 活动结束时间
            String endDate = YMTDateUtil.getBeforeOrNextDay(10);
            activityInfo.setActivityEndDate(endDate);
            // 商品活动模板号
            int activityTemplateId = 987654;
            activityInfo.setActivityTemplateId(activityTemplateId);
            // 商品活动促销类型
            int promotionType = ActivityPromotionTypeEnum.DiscountPrice.getValue();
            activityInfo.setPromotionType(promotionType);
            // 促销价格
            BigDecimal promotionPrice = new BigDecimal(1);
            activityInfo.setPromotionPrice(promotionPrice);
            // 促销价格
            BigDecimal commissionRate = new BigDecimal(0);
            activityInfo.setCommissionRate(commissionRate);
            productinfo.setActivityInfo(activityInfo);
            // 第二件商品
            // 商品id
            productinfo2.setProductId(productId);
            // 商品名称
            productinfo2.setProductName(productName);
            // 商品规格id
            String catalogId2 = TestDataManager.getRandomUUID().toString();
            productinfo2.setCatalogId(catalogId2);
            // 备货状态(1-现货 2-代购 3-FBX)
            int catalogType2 = StockStatusEnum.Spot.getValue();
            productinfo2.setStockStatusEnum(catalogType2);
            // 商品数量
            int productNum2 = 1 + new Random().nextInt(5);
            productinfo2.setProductNum(productNum2);
            // 商品一级目录id
            int firstCategoryId2 = 1;
            productinfo2.setFirstCategoryId(firstCategoryId2);
            // 商品一级目录id
            int secondCategoryId2 = 2;
            productinfo2.setSecondCategoryId(secondCategoryId2);
            // 商品一级目录id
            int thirdCategoryId2 = 3;
            productinfo2.setThirdCategoryId(thirdCategoryId2);
            // 商品品牌id
            int brandId2 = 3;
            productinfo2.setBrandId(brandId2);
            // 商品url
            productinfo2.setPictureUrl(pic);
            // 商品属性信息(按JSON格式存储，如--颜色:黑色,尺寸:XXS)
            String propetyInfo2 = "";
            productinfo2.setPropetyInfo(propetyInfo2);
            // 商品价格
            BigDecimal productPrice2 = new BigDecimal(126);
            productinfo2.setProductPrice(productPrice2);
            // 商品预付定金价格
            BigDecimal earnestPrice2 = new BigDecimal(35); // 小数点后保留2位并四舍五入
            productinfo2.setEarnestPrice(earnestPrice2);
            // 价格类型
            int priceType2 = PriceTypeEnum.NewPersonPrice.getValue();
            productinfo2.setPriceType(priceType2);
            // 买家或卖家承担关税(0-卖家承担 1-买家承担)
            int tariffType2 = 0;
            productinfo2.setTariffType(tariffType2);
            // 物流类型
            int logisticsType2 = LogisticsTypeEnum.XloboBondedDelivery.getValue();
            productinfo2.setLogisticsType(logisticsType2);
            // 保税区
            int bondedArea2 = BondedAreaEnum.NingBo.getValue();
            productinfo2.setBondedArea(bondedArea2);
            // 商品备案号
            String productRecordNo2 = "123456";
            productinfo2.setProductRecordNo(productRecordNo2);
            // SKU
            String sku2 = "1234567";
            productinfo2.setSKU(sku2);
            // 套餐编号
            String packageNo2 = "11111111";
            productinfo2.setPackageNo(packageNo2);
            // 商品退货渠道
            int productRefundChannel2 = ProductRefundChannelEnum.Official.getValue();
            productinfo2.setProductRefundChannel(productRefundChannel2);
            // 商品信息(存储格式为：Json格式)
            String productDetailInfo2 =
                    "e5a1eccf-6a14-458f-b907-35dc9a3d2713#适用人群:b13e9eb1-98d6-4d39-8c35-225758e443d3#男";
            productinfo2.setProductDetailInfo(productDetailInfo2);
            productinfo2.setActivityInfo(activityInfo);
            // 第三件商品
            // 商品id
            productinfo3.setProductId(productId);
            // 商品名称
            productinfo3.setProductName(productName);
            // 商品规格id
            String catalogId3 = TestDataManager.getRandomUUID().toString();
            productinfo3.setCatalogId(catalogId3);
            // 备货状态(1-现货 2-代购 3-FBX)
            productinfo3.setStockStatusEnum(catalogType);
            // 商品数量
            int productNum3 = 1 + new Random().nextInt(5);
            productinfo3.setProductNum(productNum3);
            // 商品一级目录id
            productinfo3.setFirstCategoryId(firstCategoryId);
            // 商品一级目录id
            productinfo3.setSecondCategoryId(secondCategoryId);
            // 商品一级目录id
            productinfo3.setThirdCategoryId(thirdCategoryId);
            // 商品品牌id
            int brandId3 = 3;
            productinfo3.setBrandId(brandId3);
            // 商品url
            productinfo3.setPictureUrl(pic);
            // 商品属性信息(按JSON格式存储，如--颜色:黑色,尺寸:XXS)
            String propetyInfo3 = "";
            productinfo3.setPropetyInfo(propetyInfo3);
            // 商品价格
            BigDecimal productPrice3 = price;
            productinfo3.setProductPrice(productPrice3);
            // 商品预付定金价格
            BigDecimal earnestPrice3 = price.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP); // 小数点后保留2位并四舍五入
            productinfo3.setEarnestPrice(earnestPrice3);
            // 价格类型
            int priceType3 = PriceTypeEnum.NewPersonPrice.getValue();
            productinfo3.setPriceType(priceType3);
            // 买家或卖家承担关税(0-卖家承担 1-买家承担)
            int tariffType3 = 0;
            productinfo3.setTariffType(tariffType3);
            // 物流类型
            int logisticsType3 = LogisticsTypeEnum.XloboBondedDelivery.getValue();
            productinfo3.setLogisticsType(logisticsType3);
            // 保税区
            int bondedArea3 = BondedAreaEnum.NingBo.getValue();
            productinfo3.setBondedArea(bondedArea3);
            // 商品备案号
            productinfo3.setProductRecordNo(productRecordNo);
            // SKU
            productinfo3.setSKU(sku);
            // 套餐编号
            productinfo3.setPackageNo(packageNo);
            // 商品退货渠道
            productinfo3.setProductRefundChannel(productRefundChannel);
            // 商品信息(存储格式为：Json格式)
            productinfo3.setProductDetailInfo(productDetailInfo);
            // 活动商品信息
            productinfo3.setActivityInfo(activityInfo);

            orderProductInfoList.add(productinfo);
            orderProductInfoList.add(productinfo2);
            orderProductInfoList.add(productinfo3);
            // 订单商品信息
            order.setOrderProductInfoList(orderProductInfoList);
            // 订单信息
            orderInfoList.add(order);
            placeorderBean.setUserId(userId);
            placeorderBean.setOrderInfoList(orderInfoList);
            placeorderCall.setData(false, placeorderBean);
            placeorderCall.callService();
            int orderId = placeorderCall.getOrderIds().getInt(0);
            int tradingId = placeorderCall.getTradingId();
            map.put("orderId", orderId);
            map.put("tradingId", tradingId);
        } catch (Exception e) {
            Logger.fail(e);
        }
        return map;
    }

}
